package com.sskj.wallet.presenter;

import com.hjq.toast.ToastUtils;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.wallet.bean.CoinListBean;
import com.sskj.wallet.bean.WithdrawMsgBean;
import com.sskj.wallet.ui.activity.WithdrawActivity;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/06/26
 */
public class WithdrawPresenter extends BasePresenter<WithdrawActivity> {

    public void getCoinLists(int type) {
        httpService.getCoinLists(type)
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<CoinListBean>>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<List<CoinListBean>>> response) {
                        mView.getCoinListsOK(response.body().getData());
                    }
                });
    }

    public void getWithdrawMsg(String pid) {
        httpService.getWithdrawMsg(pid)
                .tag(this)
                .execute(new JsonCallBack<HttpData<WithdrawMsgBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<WithdrawMsgBean>> response) {
                        mView.getWithDrawMsgOK(response.body().getData());
                    }
                });
    }

    public void withDraw(String amount, String pid, String address) {
        httpService.withDraw(amount, pid, address)
                .tag(this)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        ToastUtils.show(response.body().getMsg());
                        mView.withDrawOK();
                    }
                });
    }
}
